package com.hrbxlh.virtualization.controller.manage;

import com.hrbxlh.virtualization.param.ConfigUpdateParam;
import com.hrbxlh.virtualization.result.Result;
import com.hrbxlh.virtualization.service.ConfigService;
import com.hrbxlh.virtualization.vo.ConfigVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author cheer
 */
@RestController
@RequestMapping("/manage/config")
public class ManageConfigController {

    @Autowired
    private ConfigService configService;

    /**
     * 查询配置
     */
    @RequestMapping(value = "/query", method = RequestMethod.GET)
    public Result<ConfigVO> queryConfig() {
        ConfigVO configVO = configService.queryConfig();
        return Result.success(configVO);
    }

    /**
     * 修改配置
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Result updateConfig(@RequestBody @Valid ConfigUpdateParam configUpdateParam) {
        configService.updateConfig(configUpdateParam);
        return Result.success();
    }
}
